<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <script>
    /* 一、数组去重*/
    let arr = ['1', '2', '2', '4', '4', '5']
    // 转换成数组
    let res = [...new Set(arr)]
    console.log(res);
    /* 二、数组交集 */
    let arr2 = ['4', '5']
    let result = res.filter(item => new Set(arr2).has(item))
    console.log(result);
    /*三、 数组并集 */
    let union = [...new Set([...arr, ...arr2])]
    console.log(union);
    /* 四、数组差集 */
    let diff = res.filter(item => !(new Set(arr2).has(item)))
    console.log(diff);
  </script>
</body>

</html>